//
//  PPMeCell.m
//  PropertyManage
//
//  Created by Dreamsoul on 15-1-26.
//  Copyright (c) 2015年 com.lab603.mc. All rights reserved.
//

#import "PPMeCell.h"
#import "PPMeCellFrame.h"
#import "PPMe.h"
@interface PPMeCell()
@property (nonatomic,weak)UIImageView *backgrundView;
@property (nonatomic,weak)UIImageView *typeView;
@property (nonatomic,weak)UILabel *contentLabel;
@end
@implementation PPMeCell
+ (id)cellWithTableView:(UITableView *)tableView{
    static NSString *ID = @"meCell";
    PPMeCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell = [[PPMeCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectedBackgroundView = [[UIView alloc] init];
        //设置背景图片
        UIImageView *backgroundView = [[UIImageView alloc] init];
        backgroundView.image = [UIImage resizedImageWithName:@"timeline_card_top_background"];
        backgroundView.highlightedImage = [UIImage resizedImageWithName: @"timeline_card_top_background_highlighted"
                                           ];
        [self.contentView addSubview:backgroundView];
        self.backgroundView = backgroundView;
        
        //设置类别图片
        UIImageView *typeView = [[UIImageView alloc] init];
        [self.backgroundView addSubview:typeView];
        self.typeView = typeView;
        
        //设置文字
        UILabel *contentLabel = [[UILabel alloc] init];
        [contentLabel setBackgroundColor:[UIColor clearColor]];
        [contentLabel setTextColor:[UIColor blackColor]];
        contentLabel.numberOfLines = 0;
        contentLabel.font = [UIFont systemFontOfSize:14.0];
        [self.backgroundView addSubview:contentLabel];
        self.contentLabel = contentLabel;
        
    }
    return self;
}

-(void)setCellF:(PPMeCellFrame *)cellF{
    _cellF = cellF;
    //设置frame
    self.backgrundView.frame = cellF.backgroundViewF;
    self.typeView.frame = cellF.iconF;
    self.contentLabel.frame = cellF.typeF;
    
    //设置数据
    PPMe *me = cellF.me;
    self.typeView.image = [UIImage imageWithName:me.icon];
    self.contentLabel.text = me.typeString;
}

@end
